import os
from bo.bo import BO

class MemberManage(BO):

    def __init__(self, url, token):
        super(MemberManage, self).__init__(url, token)
        cur_path = os.path.abspath(os.path.dirname(__file__))  # 获取当前文件目录
        parent_path = os.path.dirname(cur_path)
        self.root_path = os.path.dirname(parent_path)
        self.api_info_path = f'{self.root_path}/api_infos/member_manage.yaml'

    #添加成员
    def add_member(self, params):
        return self.http_request(self.api_info_path, 'add_member',params)

    #读取成员
    def get_member(self, params):
        new_member_info = {}
        member_info = self.http_request(self.api_info_path, 'get_member', params)
        new_member_info["errcode"] = member_info["errcode"]
        new_member_info["errmsg"] = member_info["errmsg"]
        new_member_info["userid"] = member_info["userid"]
        return new_member_info

    #更新成员
    def update_member(self, params):
        return self.http_request(self.api_info_path, 'update_member', params)

    #删除成员
    def delete_member(self, params):
        return self.http_request(self.api_info_path, 'delete_member', params)


